Developer Documentation

QuickTime 4 API Documentation

QuickTime 4 Reference

| Previous | Chapter Contents | Chapter Top | Next |

Further Performance Improvement for Clipping By Using minclip and maxclip Parameters

When converting floating point values back to integer values for playback or display, clipping is often a performance issue. You want to avoid the extra comparisons and branches if possible.

This specification includes two parameters, minclip and maxclip , which provide a hint to downstream users of the audio data that no sample value is less than minclip, and no sample value is greater than maxclip. The hint is optional: if you set minclip > maxclip , that means, in effect, no hint: the samples could have any value. But if you set minclip <= maxclip , the samples must satisfy the invariants above.

In many cases, it is trivial to determine minclip and maxclip. For example, if you are recording audio to a floating point file and you are capturing 16-bit two's complement integer samples and converting the integers directly into floats, you know that minclip is -32768 and maxclip is 32767, so you ought to set the parameters.

The minclip and maxclip parameters are completely independent of slope and intercept . In the previous example, minclip and maxclip happened to be close to intercept+slope and intercept-slope, but this is not required. For example, if you know that all samples in the above example fall between -1000 and +1000, then go ahead and set minclip and maxclip to those values. The more constrained you can make the clip (without sacrificing performance), the better.

Now let's say you are playing back a floating point file, so you need to convert floating point data back into 16-bit two's complement integers. The floating point data has a slope of 32767 and an intercept of 0. Do you need to perform clipping operations? The slope and intercept parameters do not tell you this. Their purpose is to define the mapping between the data's zero amplitude value and full amplitude difference and that of an output device or on-screen waveform. From what we know so far, the data could still contain samples with the value -32768.0, or for that matter +1000000000!

You should instead consult minclip and maxclip to see if clipping is necessary. If the hint is present ( minclip <= maxclip ), and minclip and maxclip are within your desired integral range, you can omit the clipping operations.

This technique does the right thing even if the data is captured with one kind of integer (for example, 16 bit) and played back with another (for example, 24 bit). It also works if the data is synthesized in floating point.

Another issue which enters the clipping picture is how to map effectively the symmetric range of floating point samples onto the non-symmetric range of integers. This is especially important when converting to or from 8-bit integers, where one step is quite audible. Using slope , intercept , minclip , and maxclip , you can use any conversion scheme you like, and all the right hints are present to perform the conversion correctly and efficiently.


© 1998 Apple Computer, Inc.

| Previous | Chapter Contents | Chapter Top | Next |